﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="newmphase.aspx.cs" Inherits="Mocola.Net.Web.newmphase" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>新建目录</title>
    <link rel="stylesheet" href="css/content.css" type="text/css" />
    <link rel="stylesheet" href="css/ui.css" type="text/css" />
    <link rel="stylesheet" href="css/sys.css" type="text/css" />

    <script type="text/javascript" src="scripts/mootools-1.2-core.js"></script>
    <script type="text/javascript" src="scripts/mocola-funs.js"></script>
    <script type="text/javascript">         
    function jsAddItemToSelect(objItemText, objItemValue) {       
        var varItem = new Option(objItemText, objItemValue);      
        $('ddlPhaseName').options.add(varItem); 
    }  
    function jsRemoveItemFromSelect(objSelect) { 
            var selTarget =$('ddlPhaseName');
            if(selTarget.selectedIndex > -1) 
            {
                for(var i=0;i<selTarget.options.length;i++)
                {
                    if(selTarget.options[i].selected)
                    {
                        selTarget.remove(i);
                        i = i-1;
                     }
                 }
            } 
    }
    window.addEvent('domready', function() {
        var type = gup('type');
        switch (type) {
            case "3":
                jsRemoveItemFromSelect();
                jsAddItemToSelect("自定义", "-1");
                selectPhaseEvent();
                break;
            default:
                $('txtPhaseName').style.display = "block";
                $('ddlPhaseName').style.display = "none";
                break;
        }
    });   
    </script>
</head>
<body style="padding: 10px">
    <form id="frmNewMPhase">
    <div>
        <div class="title1">
            所属目录：<b id="lblProject"></b></div>
        <label id="lblType" class="label1">
        </label>
        <div style="margin-bottom:5px;">
            <select id="ddlPhaseName" name="ddlPhaseName" onchange="selectPhaseEvent()">
                <option value="-1">自定义</option>
            </select>       
        </div>
        <div style="padding:30 10 2 2;">
         <input type="text" id="txtPhaseName" name="phasename" class="input1" style="width:160px; display:none;"  maxlength="50" />        
        </div>
         <div class="onShow" style="padding-left:30px;"> * 目录名称，最大长度为50个字符。</div>   
       
        <div align="center" style="margin-top:5px;">
            <input type="button" class="btnzc" value="确认新增" onclick="addPhase()" /></div>
    </div>
    <input type="hidden" value="" id="hidUid" name="uid" />
    <input type="hidden" value="" id="hidEid" name="eid" />
    <input type="hidden" value="" id="hidType" name="type" />
    </form>
    <script type="text/javascript">
    $('lblProject').innerHTML = gup('name');
    $('hidType').value = gup('type');
    $('lblType').innerHTML = ($('hidType').value=='2')?'阶段名称：':'目录名称：';
    function selectPhaseEvent()
    {
        var v=$('ddlPhaseName').options[$('ddlPhaseName').selectedIndex].value;
        $('txtPhaseName').style.display=v.indexOf("-1")!=-1?"block":"none";
    }
    function addPhase() {      
       
        $('hidUid').value = gup('uid');
        $('hidEid').value = gup('eid');        
       
        var phasename="";
        var v = $('ddlPhaseName').options[$('ddlPhaseName').selectedIndex].value;
        //alert(v);return;
        if(v=="自定义"){
            phasename = $('txtPhaseName').value;          
        }
        else{
            phasename=$('ddlPhaseName').options[$('ddlPhaseName').selectedIndex].text;
        }
        if(phasename=='')
        {
            alert('系统提示：名称不能为空!');
            $('txtPhaseName').focus();
            return;
        } 
        else 
        {
        
               var reqValues = new Request.HTML({url:'ajax/AddMPhase.aspx',
		        onSuccess: function(html) {
		            var phaseid = html.item(0).nodeValue;
		            if(phaseid!=-1) {
		                window.parent.MochaUI.notification("项目阶段新增成功!"); 
		                window.parent.MochaUI.closeWindow(window.parent.$('winNewPhase'));
		                window.parent.MochaUI.updateContent({
    			            element:  window.parent.$('left-panel'),
    			            loadMethod: 'iframe',
    			            url: 'left-managements.aspx'
    		            });
		            } else {
		                alert('系统错误：项目阶段新增失败!请联系管理员解决此问题!');
		            }
		        },
		        onFailure: function() {
			        window.parent.MochaUI.notification('表单提交失败！');;
		        }
	        }).post($('frmNewMPhase'));
        }
    }    
    </script>
</body>
</html>